﻿using ViewMaker.Core.Controls;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using ViewMaker.Core;
using System.Collections.Generic;
using System.Windows.Controls;
using ViewMaker.Core.Tests.Controls;

namespace ViewMaker.Core.Tests
{
    [TestClass()]
    public class ItemsControlViewControlTest
    {
        [TestMethod()]
        public void 標準的なItemsControlのXAML生成()
        {
            var target = new ItemsControlViewControl { Width = 100, Item = new ViewLayoutItem { Name = "ic001", BindPath = "data" } };
            target.Item.Element = target;
            var txtItem1 = new ViewLayoutItem { Name = "txt001", Caption = "テキスト", BindPath = "textPath1" };
            txtItem1.Element = new TextBoxViewControl();
            target.Item.AddChild(txtItem1);
            var txtItem2 = new ViewLayoutItem { Name = "txt002", Caption = "テキスト", BindPath = "textPath2" };
            txtItem2.Element = new TextBoxViewControl();
            target.Item.AddChild(txtItem2);
            var xaml = target.CreateXaml(TestHelper.CreateTestParent())[0];
            var actual = TestHelper.GetFrameworkElement<ItemsControl>(xaml);
            Assert.AreEqual("ic001", actual.Name);
            Assert.AreEqual("data", actual.GetBindingExpression(ItemsControl.ItemsSourceProperty).ParentBinding.Path.Path);

        }

        [TestMethod()]
        public void ItemsControlViewControlの編集画面が表示可能()
        {
            var target = new ItemsControlViewControl { Width = 100, Item = new ViewLayoutItem { Name = "ic001", BindPath = "data" } };
            target.Item.Element = target;
            var baml = ViewUtil.BuildContent(target);
            Assert.IsNotNull(baml);
        }

    }
}
